<template>
  <div class="page">
    <h1>项目管理</h1>
    <Upload
        multiple
        type="drag"
        action='/api/upload'
        :on-progress="test">
        <div style="padding: 20px 0">
            <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
            <p>Click or drag files here to upload</p>
        </div>
    </Upload>
  </div>
</template>

<script type="text/ecmascript-6">
import XLSX from 'xlsx'
export default {
  data() {
    return {
      file: null,
      loadingStatus: false
    }
  },
  methods: {
    test(a,b,c){
      console.log(a,b,c)
    },
    uploadPic() {
      var form = document.getElementById('upload'),
        formData = new FormData(form);
      var request = new XMLHttpRequest(); // 新建XMLHttpRequest对象

      request.onreadystatechange = function () { // 状态发生变化时，函数被回调
        if (request.readyState === 4) { // 成功完成
          // 判断响应结果:
          if (request.status === 200) {
            // 成功，通过responseText拿到响应的文本:
            return 'success'
          } else {
            // 失败，根据响应码判断失败原因:
            return 'fail'
          }
        } else {
          // HTTP请求还在继续...
        }
      }

      // 发送请求:
      request.open('GET', '/api/upload');
      request.send(formData);

    }
  }
}
</script>

<style scoped>

</style>
